import Vue from 'vue'
import VueI18n from "vue-i18n";
import en from "../assets/languages/en_us.json";
import enLocal from "element-ui/lib/locale/lang/en";
import zh from "../assets/languages/zh_cn.json";
import zhLocal from "element-ui/lib/locale/lang/zh-CN";
import locale from "element-ui/lib/locale";

Vue.use(VueI18n)


const messages = {
  en:Object.assign(en,enLocal),
  zh:Object.assign(zh,zhLocal),
}

// 注册i18n实例并引入语言文件，文件格式等下解析
const i18n  = new VueI18n({
  locale: localStorage.getItem("localLanguage") || "zh",
  messages
})

locale.i18n((key,val) => i18n .t(key,val))

export default i18n ;
